Repository navigation
feat(auth): admin password reset with session revocation - #25
Merged
Merged
Conversation
- POST /api/auth/users/{id}/reset-password (admin): sets a new password for
another non-admin account, optionally requires a change at next login,
and records an audit entry without the password. Self and other admins
are refused.
- Session revocation: users carry token_version and JWTs carry it as "tv".
A token with an older version is rejected, so a reset signs out every
existing session. Tokens issued before this change carry no "tv", count
as version 0 and keep working.
- change-password now rejects reusing the current password, clears
must_change_password, signs out the user's other sessions and returns a
fresh token that the profile page stores.
- UI: Reset Password action and modal on the Users page (password
generator, require-change toggle), a "must change password" badge, and
a banner linking to Profile until the user picks their own password.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Administrators had no way to set another user's password. The only option was editing the database inside the container.
Admin reset:
POST /api/auth/users/{id}/reset-passwordchange-password), another admin returns 403, an unknown user returns 404, and unknown fields return 422.require_change(defaulttrue) setsmust_change_passwordon the account.auth.password.resetrecords the username andrequire_change, never the password.Session revocation
User.token_versionis added, and every JWT carries it astv.get_current_userrejects a token whose version is older than the stored one, returning 401 "Session revoked".tvand users without the field both count as version 0, so nobody is signed out by the deploy.Own password change
must_change_passwordand signs out the user's other sessions.ProfilePagestores so the current tab stays signed in.UI
Tests
backend/tests/test_password_reset.py(6 tests) covers:tvstill acceptedruff checkandruff format --checkare clean.CI=true npm run buildpasses.Notes
🤖 Generated with Claude Code